Skip to content

feat(cli): deploy from Cloudflare Workers Builds - #17

Merged
Madraka merged 2 commits into
mainfrom
feat/deploy-workers-builds
Oct 20, 2026
Merged

Madraka merged 2 commits into
mainfrom
feat/deploy-workers-builds

Conversation

@Madraka

@Madraka Madraka commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Why

A Deploy to Cloudflare button deploys one Worker. Cloudhal needs two, plus D1 and R2. So the button will point at a separate template repo (cloudhal-dev/cloudhal-template) whose deploy script is cloudhal deploy. Inside Workers Builds, every build is a fresh clone: no .cloudhal/, no secrets.json, no state.json. Before this change, cloudhal deploy failed with "site not found in the local store". Even with a seeded store, every build would have generated new secrets and lost what they encrypt.

What

With WORKERS_CI=1 (set by Workers Builds; DeployOptions.workersBuilds in tests), cloudhal deploy:

  • takes its names from the committed wrangler.jsonc: the connected Worker (Workers Builds requires the config to name it), the DB database's name and id, and the BLOBS bucket. A known database id means no D1 call (the default build token may lack D1 permission). An all-zero placeholder id counts as no id.
  • seeds the starter under cloudhal.json's siteId when the checkout has none (seedStarterSite gets an optional siteId). The site is pushed only if the deployment lacks it.
  • keeps secrets on the Workers. It runs wrangler secret list on both Workers and generates only the missing secrets (wrangler keeps every secret a deploy does not set; checked in wrangler's source). Shared secrets are set on both Workers together. Any list failure other than "not found" stops the deploy. The deployment token is new on every build.
  • never prints the setup link. The first build prints how the owner sets their own CLOUDHAL_SETUP_TOKEN in the dashboard and opens the link.
  • skips the downgrade guard and the cache purge on a switch, since no previous state exists. Documented as a limit.

Outside Workers Builds nothing changes. shipWorkers now takes per-Worker secrets and leaves out --secrets-file when there is nothing to set.

Guide: docs/guides/deploy-button.md. Changeset: minor (cli, core-ts; fixed group).

Tests

  • new packages/cli/test/deploy-workers-builds.test.ts: button names, placeholder id, seed and push, secrets kept across a second fresh clone, a failed secret list
  • deploy, deploy-attach, multi-site-deploy and search-deploy tests pass
  • pnpm check (run alone): lint, size check, typecheck and every package's tests pass, except @cloudhal/studio#test. That task hit hook timeouts under turbo --concurrency=3 on this machine (load average around 11). Run alone, Studio passes 1121/1121, and this PR touches no Studio file.

The README button PR comes separately and waits until the button has been tested.

🤖 Generated with Claude Code

`cloudhal deploy` now works from a fresh clone in Workers Builds
(`WORKERS_CI=1`), which the Deploy to Cloudflare button sets up:

- names come from the committed wrangler.jsonc (the Worker the button
  connected, its D1 database and R2 bucket); a database id there is used
  without a D1 call, an all-zero placeholder counts as none
- the starter site is seeded under cloudhal.json's siteId when the
  checkout has none, and pushed only when the deployment lacks it
- secrets stay on the Workers: only missing ones are generated, shared
  ones are set on both Workers together, a failed secret list stops the
  deploy; the deployment token is new on every build
- the setup link is never printed; the first build explains how the
  owner sets their own setup token

seedStarterSite takes an optional siteId. Guide: docs/guides/deploy-button.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Madraka <asker_17@msn.com>
Copilot AI balanced review requested due to automatic review settings October 20, 2026 14:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Madraka <asker_17@msn.com>
@Madraka
Madraka merged commit dda9c12 into main Oct 20, 2026
5 checks passed
Madraka added a commit that referenced this pull request Oct 20, 2026
feat(cli): deploy from Cloudflare Workers Builds
Madraka added a commit that referenced this pull request Oct 20, 2026
Deploy from Cloudflare Workers Builds (#17), one-click page publish in
Studio (#14), computed values in surface conditions (#15), a 30 s Chrome
start (#16).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
@Madraka
Madraka deleted the feat/deploy-workers-builds branch October 20, 2026 21:35
Madraka added a commit that referenced this pull request Nov 11, 2026
ADR-0046 names field_operation_unsupported, the referrer-publish refusal,
the text anchors, the untested R9 and R14 and what moves to 2b; the RFC
status line says step 2 is split. The changeset drops the removed job and
adds the list-values rebuild.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Madraka <8898640+Madraka@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants